home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
shadow-i.002
/
shadow-i
/
shadow-ina-box-1.1
/
modify.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-13
|
2KB
|
96 lines
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
void main()
{
FILE *f1, *f2;
char string[100];
int ftp=0, xlock=0;
/*
Looking if is root who is compiling this package ...
*/
if( getuid() != 0 )
{
printf( "\n Only ROOT can install shadow package. Sorry !\n\n" );
system( "touch Fail" );
exit( 1 );
}
/*
Opening the file /etc/inetd.conf in order to modify the line containing
wu.ftpd into in.ftpd, the new ftp daemon with shadow support.
*/
f1 = fopen( "/etc/inetd.conf", "r" );
f2 = fopen( "/tmp/inetd.conf", "w" );
while( !feof( f1 ) )
{
fgets( string, 90, f1 );
if ( !strncmp( string, "ftp", 3 ) )
{
string[ strlen( string ) - 8 ] = '\0';
strcat( string, "ftpd\n" );
ftp = 1;
}
if ( !strncmp( string, "pop3", 4 ) )
{
string[ strlen( string ) - 9 ] = '\0';
strcat( string, "popper\n" );
ftp = 1;
}
if ( !feof( f1 ) )
fputs( string, f2 );
}
fclose( f1 );
fclose( f2 );
if( ftp )
{
system( "mv -f /etc/inetd.conf /etc/inetd.conf.orig" );
system( "mv -f /tmp/inetd.conf /etc/inetd.conf" );
system( "chmod go+r /etc/inetd.conf" );
}
else
{
printf("\nCan't find /etc/inetd.conf, wu.ftpd or in.pop3 command line in it!\n\n");
}
/*
Opening the file /usr/X11R6/lib/X11/config/linux.cf in order to set the
variable HasShadowPassword to YES for a correct compiling of xlockmore.
File path is set for X11R6 release. If you use a previous version modify
it !
*/
f1 = fopen( "/usr/X11R6/lib/X11/config/linux.cf", "r" );
f2 = fopen( "/tmp/linux.cf", "w" );
while( !feof( f1 ) )
{
fgets( string, 90, f1 );
if ( !strncmp( string, "#define HasShadowPasswd", 23 ) )
{
string[ strlen( string ) - 3 ] = '\0';
strcat( string, "YES\n" );
xlock = 1;
}
if ( !feof( f1 ) )
fputs( string, f2 );
}
fclose( f1 );
fclose( f2 );
if( xlock )
{
system( "mv -f /usr/X11R6/lib/X11/config/linux.cf /usr/X11R6/lib/X11/config/linux.cf.orig" );
system( "mv -f /tmp/linux.cf /usr/X11R6/lib/X11/config/linux.cf" );
system( "chmod go+r /usr/X11R6/lib/X11/config/linux.cf" );
}
else
{
printf( "\nCan't find /usr/X11R6/lib/X11/config/linux.cf or HasShadowPasswd variable in it!\n\n" );
}
}